{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0       1.00      1.00      1.00        53\n",
      "           1       1.00      1.00      1.00        50\n",
      "           2       1.00      1.00      1.00        47\n",
      "           3       0.98      0.98      0.98        54\n",
      "           4       1.00      1.00      1.00        60\n",
      "           5       1.00      0.98      0.99        66\n",
      "           6       0.98      1.00      0.99        53\n",
      "           7       0.98      0.98      0.98        55\n",
      "           8       0.95      0.98      0.97        43\n",
      "           9       0.97      0.95      0.96        59\n",
      "\n",
      "    accuracy                           0.99       540\n",
      "   macro avg       0.99      0.99      0.99       540\n",
      "weighted avg       0.99      0.99      0.99       540\n",
      "\n",
      "[[53  0  0  0  0  0  0  0  0  0]\n",
      " [ 0 50  0  0  0  0  0  0  0  0]\n",
      " [ 0  0 47  0  0  0  0  0  0  0]\n",
      " [ 0  0  0 53  0  0  0  0  1  0]\n",
      " [ 0  0  0  0 60  0  0  0  0  0]\n",
      " [ 0  0  0  0  0 65  1  0  0  0]\n",
      " [ 0  0  0  0  0  0 53  0  0  0]\n",
      " [ 0  0  0  0  0  0  0 54  0  1]\n",
      " [ 0  0  0  0  0  0  0  0 42  1]\n",
      " [ 0  0  0  1  0  0  0  1  1 56]]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAxsAAAGyCAYAAACMUtnGAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAuPElEQVR4nO3dfZSWdZ0/8M/wIMPTMoig4sMMKJokimFqpDL4hKnJuOsRLYsxKdbVAlejh1MyqGUeJUbDxLKEjD1mLEJrrKbJ7BGPi5IOK66sRIylpoIyUKkgcP3+MOYnAjJ43d95uHm9zplz5Jrr+7k/9z2f+c799rrnnpIsy7IAAAAosA6t3QAAAFCchA0AACAJYQMAAEhC2AAAAJIQNgAAgCSEDQAAIAlhAwAASELYAAAAkhA2AACAJIQNgFZQUVER1dXVTf+uq6uLkpKSqKura7We3u/9PbaEysrKOPLIIwtaszXuBwDvEjaAPc7MmTOjpKSk6aO0tDQOO+ywuOKKK+LVV19t7fZ2y4IFC6KmpqZVeygpKYkrrriiVXsAoG3q1NoNALSWa6+9NgYMGBBvv/12LFq0KG6//fZYsGBBLFu2LLp169aivZx88snx1ltvxV577bVb6xYsWBC33XZbqwcOANgRYQPYY33qU5+KY489NiIixo0bF3369Invf//7MX/+/Ljooot2uOZvf/tbdO/eveC9dOjQIUpLSwteFwBak5dRAfzdKaecEhERq1atioiI6urq6NGjR6xcuTLOOuus6NmzZ3z2s5+NiIgtW7ZEbW1tfPSjH43S0tLYd999Y/z48bF27dptamZZFtdff30ceOCB0a1btxg5cmQ8++yz2932zn5nY/HixXHWWWdF7969o3v37nHUUUfFLbfc0tTfbbfdFhGxzcvCtip0j3nMnz8/zj777Ojfv3906dIlDjnkkLjuuuti8+bNOzz/d7/7XQwfPjy6du0aAwYMiBkzZmx3zoYNG2Ly5Mlx6KGHRpcuXeKggw6KSZMmxYYNGz6wl3feeSemTJkSgwYNitLS0ujTp0+ceOKJ8dBDDxXkvgLw/7myAfB3K1eujIiIPn36NB3btGlTjBo1Kk488cS4+eabm15eNX78+Jg5c2Zccskl8ZWvfCVWrVoV06dPj6effjoee+yx6Ny5c0REXHPNNXH99dfHWWedFWeddVY89dRTccYZZ8TGjRt32c9DDz0U55xzTuy///4xYcKE2G+//eK5556L+++/PyZMmBDjx4+Pl19+OR566KG4++67t1vfEj0218yZM6NHjx7xr//6r9GjR4945JFH4pprron169fHTTfdtM25a9eujbPOOisuuOCCuOiii+Lee++Nyy67LPbaa6/4whe+EBHvBqlzzz03Fi1aFF/60pfiiCOOiGeeeSamTZsWzz//fMybN2+nvdTU1MQNN9wQ48aNi+OOOy7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r1q1rOu/99+P666/PjjvuuKysrCzr2rVr9pGPfCT7zne+0/S2ugAUTkmW7eR/LQEAAOTgdzYAAIAkhA0AACAJYQMAAEhC2AAAAJIQNgAAgCSEDQAAIAlhAwAASELYAAAAkhA2AACAJIQNAAAgCWEDAABIQtgAAACSEDYAAIAkhA0AACAJYQMAAEhC2AAAAJIQNgAAgCSEDQAAIAlhAwAASELYAAAAkhA2AACAJIQNAAAgCWEDAABIQtgAAACSEDYAAIAkhA0AACAJYQMAAEhC2AAAAJIQNgAAgCSEDQAAIAlhAwAASELYAAAAkhA2AACAJPb4sNHQ0BAlJSVx8803F6xmXV1dlJSURF1dXcFqUpzMH63J/NHazCCtyfy1jHYZNmbOnBklJSWxZMmS1m4lqV/84hfxiU98Irp37x5lZWUxfPjweOSRR1q7rT3enjB/99xzT3zsYx+L0tLS6Nu3b1x66aWxZs2a1m6LKP75u++++2LUqFHRv3//6NKlSxx44IFx/vnnx7Jly1q7Nf6u2GewoqIiSkpKdvgxaNCg1m5vj1fs8zd37twYM2ZMDBw4MLp16xaHH354XHXVVdHY2NjarX1onVq7AXaspqYmrr322jj//POjuro63nnnnVi2bFm89NJLrd0aRe7222+Pf/mXf4lTTz01vv/978eLL74Yt9xySyxZsiQWL14cpaWlrd0iReyZZ56J3r17x4QJE2KfffaJV155JX7605/GcccdF48//ngcffTRrd0iRa62tjb++te/bnPshRdeiG9961txxhlntFJX7Cm+9KUvRf/+/ePiiy+Ogw8+OJ555pmYPn16LFiwIJ566qno2rVra7e424SNNui///u/49prr42pU6fGlVde2drtsAfZuHFjfPOb34yTTz45HnrooSgpKYmIiOHDh8enP/3p+PGPfxxf/vKXW7lLitk111yz3bFx48bFgQceGLfffnvMmDGjFbpiT1JVVbXdseuvvz4iIj772c+2cDfsaebMmROVlZXbHBs2bFiMHTs2Zs+eHePGjWudxnJoly+jao6NGzfGNddcE8OGDYtevXpF9+7d46STToqFCxfudM20adOivLw8unbtGiNGjNjhZfvly5fH+eefH3vvvXeUlpbGscceG7/61a922c+bb74Zy5cvb9ZLUWpra2O//faLCRMmRJZl2/0fFtq+9jp/y5Yti8bGxhgzZkxT0IiIOOecc6JHjx5xzz337PK2aH3tdf52pl+/ftGtW7d2/TKCPU2xzeC//du/xYABA2L48OEfaj0tqz3P3/uDRkTEeeedFxERzz333C7Xt0VFGzbWr18fd955Z1RWVsaNN94YNTU1sXr16hg1alTU19dvd/7PfvazuPXWW+Pyyy+Pb3zjG7Fs2bI45ZRT4tVXX20659lnn40TTjghnnvuufj6178eU6dOje7du0dVVVXcd999H9jPE088EUcccURMnz59l73/9re/jY9//ONx6623Rt++faNnz56x//77N2stbUN7nb8NGzZEROzwMm3Xrl3j6aefji1btjTjEaA1tdf5e6/GxsZYvXp1PPPMMzFu3LhYv359nHrqqc1eT+sqhhnc6umnn47nnnsuPvOZz+z2WlpHMc1fRMQrr7wSERH77LPPh1rf6rJ26K677soiInvyySd3es6mTZuyDRs2bHNs7dq12b777pt94QtfaDq2atWqLCKyrl27Zi+++GLT8cWLF2cRkV155ZVNx0499dRsyJAh2dtvv910bMuWLdnw4cOzQYMGNR1buHBhFhHZwoULtzs2efLkD7xvb7zxRhYRWZ8+fbIePXpkN910U/aLX/wiO/PMM7OIyGbMmPGB60mvmOdv9erVWUlJSXbppZduc3z58uVZRGQRka1Zs+YDa5BWMc/fex1++OFNM9ejR4/sW9/6VrZ58+ZmryedPWUGt7rqqquyiMj+93//d7fXUnh72vxlWZZdeumlWceOHbPnn3/+Q61vbUV7ZaNjx46x1157RUTEli1b4o033ohNmzbFscceG0899dR251dVVcUBBxzQ9O/jjjsujj/++FiwYEFERLzxxhvxyCOPxAUXXBB/+ctfYs2aNbFmzZp4/fXXY9SoUbFixYoP/OXtysrKyLIsampqPrDvrS+Zev311+POO++Mq6++Oi644IL49a9/HYMHD2563ShtW3udv3322ScuuOCCmDVrVkydOjX+8Ic/xKOPPhpjxoyJzp07R0TEW2+9tbsPBy2svc7fe911113xwAMPxA9/+MM44ogj4q233orNmz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rXvx5Tp06N7t27R1VVVdx3330f2M8TTzwRRxxxREyfPr3Qd5U2qBjmb+DAgdGrV6/o2bNnXHzxxdv0QttWDPP3Xq+88kpEhP/L3I4UwwzaA9uvYpi/92r3e2DWDt11111ZRGRPPvnkTs/ZtGlTtmHDhm2OrV27Ntt3332zL3zhC03HVq1alUVE1rVr1+zFF19sOr548eIsIrIrr7yy6dipp56aDRkyJHv77bebjm3ZsiUbPnx4NmjQoKZjCxcuzCIiW7hw4XbHJk+evFv39aabbsoiIlu1atVurSOdYp+/2tra7Iorrshmz56dzZkzJ5swYULWqVOnbNCgQdm6det2uZ60in3+duTSSy/NOnbsmD3//PMfaj2FVewzaA9s24p9/nakve+BRRs23mvz5s3Z66+/nq1evTo7++yzs6FDhzZ9buugXXTRRdutO/7447PDDz88y7Ise/3117OSkpLsuuuuy1avXr3Nx5QpU7KIaBrUHQ3ahyVstD170vxtNXv27CwishtuuKFgNflw9rT52zp7kyZNKkg98tvTZjDL7IFtyZ42f8WwBxbty6giImbNmhVHHXVUlJaWRp8+faJv377x61//OtatW7fduYMGDdru2GGHHdb0lrO///3vI8uy+Pa3vx19+/bd5mPy5MkREfHaa68lvT+0L8U0f5/5zGdiv/32i4cffjjZbVBYxTB/jz76aFx66aUxatSo+M53vlPw+qRVDDO4lT2w/SmG+SuWPbBo343q5z//eVRXV0dVVVV89atfjX79+kXHjh3jhhtuiJUrV+52vS1btkRExNVXXx2jRo3a4TmHHnporp4pHsU4fwcddFC88cYbSW+DwiiG+Vu6dGmce+65ceSRR8acOXOiU6ei/XFVlIphBt/PHth+FMP8FdMe2H4734U5c+bEwIEDY+7cuVFSUtJ0fGsCfb8VK1Zsd+z555+PioqKiHj3F8UiIjp37hynnXZa4RumqBTb/GVZFg0NDXHMMce0+G2z+9r7/K1cuTLOPPPM6NevXyxYsGCbv3VA+9DeZ/D97IHtS3ufv2LbA4v2ZVRb//hO9p63rFu8eHE8/vjjOzx/3rx58dJLLzX9+4knnojFixfHpz71qYiI6N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/plain": [
       "<Figure size 1000x500 with 10 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np  \n",
    "import matplotlib.pyplot as plt  \n",
    "from sklearn import datasets  \n",
    "from sklearn.model_selection import train_test_split  \n",
    "from sklearn import svm  \n",
    "from sklearn.metrics import classification_report, confusion_matrix  \n",
    "\n",
    "# 加载手写数字数据集  \n",
    "digits = datasets.load_digits()   \n",
    "\n",
    "# 特征和标签  \n",
    "X = digits.data  \n",
    "y = digits.target  \n",
    "\n",
    "# 划分训练集和测试集  \n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)  \n",
    "\n",
    "# 创建SVM模型  \n",
    "model = svm.SVC(gamma='scale')  \n",
    "\n",
    "# 训练模型  \n",
    "model.fit(X_train, y_train)  \n",
    "\n",
    "# 进行预测  \n",
    "y_pred = model.predict(X_test)  \n",
    "\n",
    "# 打印分类报告和混淆矩阵  \n",
    "print(classification_report(y_test, y_pred))  \n",
    "print(confusion_matrix(y_test, y_pred))  \n",
    "\n",
    "# 可视化部分预测结果  \n",
    "def plot_digits(data, labels, title):  \n",
    "    plt.figure(figsize=(10, 5))  \n",
    "    for i in range(10):  \n",
    "        plt.subplot(2, 5, i + 1)  \n",
    "        plt.imshow(data[i].reshape(8, 8), cmap='gray')  \n",
    "        plt.title(f\"Label: {labels[i]}\")  \n",
    "        plt.axis('off')  \n",
    "    plt.suptitle(title)  \n",
    "    plt.show()  \n",
    "\n",
    "# 绘制测试集中的前10个数字及其预测  \n",
    "plot_digits(X_test, y_pred, title='Predicted Labels')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0       1.00      1.00      1.00        53\n",
      "           1       1.00      1.00      1.00        50\n",
      "           2       1.00      1.00      1.00        47\n",
      "           3       0.98      0.98      0.98        54\n",
      "           4       1.00      1.00      1.00        60\n",
      "           5       1.00      0.98      0.99        66\n",
      "           6       0.98      1.00      0.99        53\n",
      "           7       0.98      0.98      0.98        55\n",
      "           8       0.95      0.98      0.97        43\n",
      "           9       0.97      0.95      0.96        59\n",
      "\n",
      "    accuracy                           0.99       540\n",
      "   macro avg       0.99      0.99      0.99       540\n",
      "weighted avg       0.99      0.99      0.99       540\n",
      "\n",
      "[[53  0  0  0  0  0  0  0  0  0]\n",
      " [ 0 50  0  0  0  0  0  0  0  0]\n",
      " [ 0  0 47  0  0  0  0  0  0  0]\n",
      " [ 0  0  0 53  0  0  0  0  1  0]\n",
      " [ 0  0  0  0 60  0  0  0  0  0]\n",
      " [ 0  0  0  0  0 65  1  0  0  0]\n",
      " [ 0  0  0  0  0  0 53  0  0  0]\n",
      " [ 0  0  0  0  0  0  0 54  0  1]\n",
      " [ 0  0  0  0  0  0  0  0 42  1]\n",
      " [ 0  0  0  1  0  0  0  1  1 56]]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np  \n",
    "from sklearn import datasets  \n",
    "from sklearn.model_selection import train_test_split  \n",
    "from sklearn import svm  \n",
    "from sklearn.metrics import classification_report, confusion_matrix  \n",
    "\n",
    "# 加载手写数字数据集  \n",
    "digits = datasets.load_digits()  \n",
    "\n",
    "# 特征和标签  \n",
    "X = digits.data  \n",
    "y = digits.target  \n",
    "\n",
    "# 划分训练集和测试集  \n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)  \n",
    "\n",
    "# 创建SVM模型  \n",
    "model = svm.SVC(gamma='scale')  #括号内部为重要的参数，不可删除\n",
    "\n",
    "# 训练模型  \n",
    "model.fit(X_train, y_train)  \n",
    "\n",
    "# 进行预测  \n",
    "y_pred = model.predict(X_test)  \n",
    "\n",
    "# 打印分类报告和混淆矩阵  \n",
    "print(classification_report(y_test, y_pred))  \n",
    "print(confusion_matrix(y_test, y_pred))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "pytorchgpu",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.20"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
